<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        *{
            margin: 0;
            padding: 0;
            list-style: none;
            border: none;
        }
        #progress{
            width: 1000px;
            height: 35px;
            line-height: 35px;
            /*background: #cccccc;*/
            margin: 100px auto;
            position: relative;
        }
        #progress_bar{
            width: 900px;
            height: 100%;
            background: #5e6268;
            border-radius: 8px;
            position: relative;
        }
        #progress_value{
            position: absolute;
            right: 40px;
            top: 0;
        }
        #progress_bar_fg{
            width: 0px;
            height: 100%;
            background: orangered;
            border-top-left-radius: 8px;
            border-bottom-left-radius: 8px;
        }
        #progress_bar span{
            width: 25px;
            height: 49px;
            background-color: orangered;
            position: absolute;
            left:0px;
            top:-7px;
            border-radius: 5px;
            cursor: pointer;
        }
    </style>
</head>
<body>
<div id="progress">
    <div id="progress_bar">
        <div id="progress_bar_fg"></div>
        <span></span>
    </div>
    <div id="progress_value">0%</div>
</div>
<script>
    window.onload=function () {
        var progress = document.getElementById("progress")
        var progress_bar = progress.children[0];
        var progress_value = progress.children[1];
        var progress_bar_fg = progress_bar.children[0];
        var mask = progress_bar.children[1];
        mask.onmousedown = function (event) {
            var e = event || window.event;
            var offsetleft = e.clientX - mask.offsetLeft;

            //console.log(offsetleft)
            //console.log(e.clientX)
            document.onmousemove=function (event) {
                var e = event || window.event;
                var x = e.clientX - offsetleft;
                //console.log(offsetleft)
                //console.log(e.clientX)
                //console.log(x)
                if(x<0){
                    x=0;
                }else if(x>progress_bar.offsetWidth-mask.offsetWidth){
                    x=progress_bar.offsetWidth-mask.offsetWidth;
                }
                mask.style.left = x+"px";
                progress_bar_fg.style.width = x+"px";
                progress_value.innerHTML = parseInt(x/(progress_bar.offsetWidth-mask.offsetWidth)*100)+"%"
                return false;
            };
            document.onmouseup = function () {
                document.onmousemove=null;
            };
        }

    }
</script>
</body>
</html>